<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>02-while</title>
</head>
<body>
    <script>
        /* 
            while 循环 while 当......的时候
            语法结构：
                while(条件判断){
                    逻辑体;
                }
            执行顺序：
                1.  初始化变量
                2.  条件判断
                3.1 true 逻辑体
                3.2 false 跳出整个代码块
                4.  重复 2. 3. 4.
            重点： 变化条件，防止死循环
        */
       let num = 0;
       while (num < 5){
           console.log('ok');
        //    console.log('<br>');
           num++;
       }

       console.log('-----------');
       //  100 求和案例

       let sum = 0;
       for (let i=0; i<=100; i++){
           sum = sum + i;
       }
       console.log(sum);
    </script>
</body>
</html>